home *** CD-ROM | disk | FTP | other *** search
/ Java for 3D & VRML Worlds / Java for 3d and VRML Worlds.iso / examples / chap03 / MoveIt.java < prev    next >
Text File  |  1996-10-18  |  708b  |  31 lines

  1. import vrml.*;
  2. import vrml.field.*;
  3. import vrml.node.*;
  4.  
  5. public class MoveIt extends Script {
  6.  
  7.   private SFBool on;      // status of on-off
  8.   float red[] =  { 1, 0, 0 };      // RGB(Red)
  9.   float blue[] = { 0, 0, 1 };      // RGB(Blue)
  10.   private SFNode theNode ;
  11.   private SFVec3f position;
  12.  
  13.   public void initialize() {   
  14.  
  15.     theNode = (SFNode) getField("node");
  16.     
  17.   }
  18.  
  19.   public void processEvent(Event e) {
  20.     ConstSFBool v = (ConstSFBool)e.getValue();
  21.     Node node;
  22.  
  23.     if(v.getValue()){
  24.       node = (Node)(theNode.getValue());
  25.       
  26.       position = (SFVec3f)(node.getExposedField("translation"));
  27.       position.setValue((position.getX() + 5), 0, 0);
  28.     }
  29.   }
  30. }
  31.